/**
 * Created by Sihan on 2017/5/18.
 */

//load data for fuwa
function morris_data(url, eId, opts) {
    var loadFailure = "加载数据失败";
    //var loadSuccess = "数据加载成功";
    var lineColors = ["#FFF", "#000"];
    var o = {
       element: eId
    };
    o = $.extend(o, opts);
    requestData(url, 'get', null, eId, function (state, datas) {
         if(state === 'failure') {
            Alert(loadFailure, "danger");
            $("#" + eId).html(loadFailure);
         }else{
            //Alert(loadSuccess, "success");
            o = $.extend(o, {data: datas.msg});
            Morris.Line(o);
         }
    });
}

 $(function () {
     var fuwaOpts = {
         xkey: 'day',
         ykeys: ['value'],
         labels: ['福娃'],
         xLabels: "day",
         //pointSize: 3,
         //hideHover: 'auto',
         resize: false,
         parseTime: false
     };
     //福娃总数
     morris_data('/fuwachat/fuwa?isAjax=1', 'fuwa-chart', fuwaOpts);
     //商业总数
     morris_data('/fuwachat/fuwa-i?isAjax=1', 'fuwa-i-chart', fuwaOpts);
     //缘分总数
     morris_data('/fuwachat/fuwa-c?isAjax=1', 'fuwa-c-chart', fuwaOpts);
     //商业已藏
     morris_data('/fuwachat/fuwa-i-hide?isAjax=1', 'fuwa-i-hide-chart', fuwaOpts);
     //缘分已藏
     morris_data('/fuwachat/fuwa-c-hide?isAjax=1', 'fuwa-c-hide-chart', fuwaOpts);
     //商业
     morris_data('/fuwachat/fuwa-i-caught?isAjax=1', 'fuwa-i-caught-chart', fuwaOpts);
     //缘分
     morris_data('/fuwachat/fuwa-c-caught?isAjax=1', 'fuwa-c-caught-chart', fuwaOpts);
 });